<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
	<script type="text/javascript">
		function replaceAll(str,targetStr,newStr){
			while (str.indexOf(targetStr) != -1){
				str = str.replace(targetStr,newStr)
			}			
			return str
		}
		
		function findAll(str,targetStr){
			var s = ""
			var i = -1
			while (str.indexOf(targetStr,i+1) != -1){
				s += (str.indexOf(targetStr,i+1)+" ")
				i = str.indexOf(targetStr,i+1)
			}
			return s
		}
		var str = "i am because you are"
		document.writeln(str,'<br/>')
		document.writeln(replaceAll(str,"you","world"),'<br/>')
		document.writeln(findAll(str,"i"),'<br/>')
	</script>
</html>